import { GetTableData } from "@/api/common";
import { requestUrl } from "@/api/request";

let tableLoadData = {
  data() {
    return {};
  },
  created() {

  },
  mounted() {
    this.LoadData();
  },
  methods: {
    LoadData() {
      let requestJson = this.tableConfig.requestData;
      let requestData = {
        url: requestUrl[requestJson.url],
        method: requestJson.method,
        data: requestJson.data
      };
      GetTableData(requestData).then((res) => {
        let resData = res.data.data.data;
        if (resData && resData.length > 0) {
          // 更新数据
          this.tableData = resData;
          this.total = res.data.data.total;
        }
      }).catch((error) => {
        console.log(error);
      });
    }
  }
};
export default tableLoadData;
